import pytest
from common.request_util_test import RequestUtil
from common.test_yaml_util_test import YamlUtil

class TestExtManagement:
    @pytest.mark.parametrize('yaml', YamlUtil().read_testcase_yaml('v24.06/extManagement/POST_change_consoleplugin_web_enabled_stat.yaml'))
    def test_change_consoleplugin_web_enabled_stat(self, yaml, get_env_info):
        # 更改扩展界面启用状态
        baseUrl = get_env_info
        url = baseUrl + yaml['request']['url']
        method = yaml['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == yaml['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('yaml', YamlUtil().read_testcase_yaml('v24.06/extManagement/GET_get_consoleplugin_list.yaml'))
    def test_get_consoleplugin_list(self, yaml, get_env_info):
        # 获取ConsolePlugin列表
        baseUrl = get_env_info
        url = baseUrl + yaml['request']['url']
        method = yaml['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == yaml['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('yaml', YamlUtil().read_testcase_yaml('v24.06/extManagement/GET_get_consoleplugin_web_enabled_stat.yaml'))
    def test_get_consoleplugin_web_enabled_stat(self, yaml, get_env_info):
        # 获取扩展界面启用状态
        baseUrl = get_env_info
        url = baseUrl + yaml['request']['url']
        method = yaml['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == yaml['validate'][0]['equals']['status_code']

    @pytest.mark.parametrize('yaml', YamlUtil().read_testcase_yaml('v24.06/extManagement/GET_get_specefied_consoleplugin.yaml'))
    def test_get_specefied_consoleplugin(self, yaml, get_env_info):
        # 获取ConsolePlugin列表
        baseUrl = get_env_info
        url = baseUrl + yaml['request']['url']
        method = yaml['request']['method']
        req = RequestUtil().send_request(method, url)
        assert req.status_code == yaml['validate'][0]['equals']['status_code']